<template>
  <view class="featured-container">
    <!-- 顶部banner -->
    <view class="banner">
      <image src="/static/featured/banner.jpg" mode="aspectFill" />
      <view class="overlay"></view>
      <view class="banner-content">
        <text class="title">特色医疗</text>
        <text class="subtitle">专业医疗团队，优质诊疗服务</text>
      </view>
    </view>
    
    <!-- 特色项目列表 -->
    <view class="featured-list">
      <!-- 中医特色 -->
      <view class="featured-item" @tap="navigateTo('/pages/featured/tcm')">
        <image src="/static/featured/tcm.jpg" mode="aspectFill" class="bg-image" />
        <view class="content">
          <view class="info">
            <text class="name">中医特色诊疗</text>
            <text class="desc">传承千年中医精华，守护您的健康</text>
          </view>
          <view class="tags">
            <text>针灸推拿</text>
            <text>中药调理</text>
            <text>艾灸养生</text>
          </view>
        </view>
      </view>
      
      <!-- 跨境医疗 -->
      <view class="featured-item" @tap="navigateTo('/pages/featured/cross-border')">
        <image src="/static/featured/cross-border.jpg" mode="aspectFill" class="bg-image" />
        <view class="content">
          <view class="info">
            <text class="name">跨境医疗服务</text>
            <text class="desc">连接全球优质医疗资源</text>
          </view>
          <view class="tags">
            <text>专家会诊</text>
            <text>转诊服务</text>
            <text>康复护理</text>
          </view>
        </view>
      </view>
      
      <!-- 专家门诊 -->
      <view class="featured-item" @tap="navigateTo('/pages/featured/expert')">
        <image src="/static/featured/expert.jpg" mode="aspectFill" class="bg-image" />
        <view class="content">
          <view class="info">
            <text class="name">专家门诊</text>
            <text class="desc">汇聚顶尖医疗专家</text>
          </view>
          <view class="tags">
            <text>名医问诊</text>
            <text>远程会诊</text>
            <text>特需门诊</text>
          </view>
        </view>
      </view>
      
      <!-- 特色科室 -->
      <view class="featured-item" @tap="navigateTo('/pages/featured/department')">
        <image src="/static/featured/department.jpg" mode="aspectFill" class="bg-image" />
        <view class="content">
          <view class="info">
            <text class="name">特色科室</text>
            <text class="desc">专业化诊疗服务</text>
          </view>
          <view class="tags">
            <text>心血管中心</text>
            <text>妇产中心</text>
            <text>康复中心</text>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 医生团队 -->
    <view class="section">
      <view class="section-header">
        <text class="title">医生团队</text>
        <text class="more">查看全部</text>
      </view>
      <scroll-view 
        scroll-x 
        class="doctor-list"
        :show-scrollbar="false"
      >
        <view 
          class="doctor-item"
          v-for="(item, index) in doctors"
          :key="index"
          @tap="viewDoctor(item)"
        >
          <image :src="item.avatar" mode="aspectFill" class="avatar" />
          <text class="name">{{ item.name }}</text>
          <text class="title">{{ item.title }}</text>
          <text class="specialty">{{ item.specialty }}</text>
        </view>
      </scroll-view>
    </view>
    
    <!-- 治疗案例 -->
    <view class="section">
      <view class="section-header">
        <text class="title">治疗案例</text>
        <text class="more">查看全部</text>
      </view>
      <view class="case-list">
        <view 
          class="case-item"
          v-for="(item, index) in cases"
          :key="index"
          @tap="viewCase(item)"
        >
          <image :src="item.image" mode="aspectFill" class="case-image" />
          <view class="content">
            <text class="title">{{ item.title }}</text>
            <text class="desc">{{ item.desc }}</text>
            <view class="meta">
              <text class="doctor">主治医师：{{ item.doctor }}</text>
              <text class="date">{{ item.date }}</text>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

// 医生列表
const doctors = ref([
  {
    id: 1,
    name: '张医生',
    title: '主任医师',
    specialty: '中医科',
    avatar: '/static/doctor/tcm1.jpg'
  },
  {
    id: 2,
    name: '李医生',
    title: '副主任医师',
    specialty: '心内科',
    avatar: '/static/doctor/tcm2.jpg'
  }
])

// 案例列表
const cases = ref([
  {
    id: 1,
    title: '颈椎病针灸治疗案例',
    desc: '通过针灸配合推拿，显著改善患者颈椎不适...',
    image: '/static/tcm/case1.jpg',
    doctor: '张医生',
    date: '2024-03-20'
  },
  {
    id: 2,
    title: '失眠中药调理案例',
    desc: '采用中药辨证施治，改善患者睡眠质量...',
    image: '/static/tcm/case2.jpg',
    doctor: '李医生',
    date: '2024-03-18'
  }
])

// 页面跳转
const navigateTo = (url) => {
  uni.navigateTo({
    url,
    fail: (err) => {
      console.error('跳转失败:', err)
      uni.showToast({
        title: '该功能即将上线',
        icon: 'none'
      })
    }
  })
}

// 查看医生详情
const viewDoctor = (doctor) => {
  uni.navigateTo({
    url: `/pages/doctor/detail?id=${doctor.id}`
  })
}

// 查看案例详情
const viewCase = (case_) => {
  uni.navigateTo({
    url: `/pages/featured/case?id=${case_.id}`
  })
}
</script>

<style lang="scss">
.featured-container {
  min-height: 100vh;
  background: $bg-color;
  
  .banner {
    position: relative;
    height: 400rpx;
    
    image {
      width: 100%;
      height: 100%;
    }
    
    .overlay {
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background: linear-gradient(to bottom, rgba(0,0,0,0.2), rgba(0,0,0,0.6));
    }
    
    .banner-content {
      position: absolute;
      left: 40rpx;
      bottom: 40rpx;
      color: #fff;
      
      .title {
        font-size: 48rpx;
        font-weight: bold;
        margin-bottom: 12rpx;
        display: block;
        text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.2);
      }
      
      .subtitle {
        font-size: 28rpx;
        opacity: 0.9;
        display: block;
        text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.2);
      }
    }
  }
  
  .featured-list {
    padding: 30rpx;
    
    .featured-item {
      position: relative;
      height: 360rpx;
      border-radius: $radius-lg;
      overflow: hidden;
      margin-bottom: 30rpx;
      
      &:last-child {
        margin-bottom: 0;
      }
      
      .bg-image {
        width: 100%;
        height: 100%;
      }
      
      .content {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 30rpx;
        background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
        
        .info {
          margin-bottom: 20rpx;
          
          .name {
            font-size: 36rpx;
            color: #fff;
            font-weight: bold;
            margin-bottom: 8rpx;
            display: block;
          }
          
          .desc {
            font-size: 26rpx;
            color: rgba(255,255,255,0.9);
          }
        }
        
        .tags {
          text {
            display: inline-block;
            font-size: 24rpx;
            color: #fff;
            background: rgba(255,255,255,0.2);
            padding: 4rpx 16rpx;
            border-radius: $radius-sm;
            margin-right: 16rpx;
          }
        }
      }
      
      &:active {
        transform: scale(0.98);
      }
    }
  }
  
  .section {
    background: #fff;
    margin: 20rpx 30rpx;
    padding: 30rpx;
    border-radius: $radius-lg;
    
    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20rpx;
      
      .title {
        font-size: 32rpx;
        color: $text-primary;
        font-weight: bold;
      }
      
      .more {
        font-size: 28rpx;
        color: $text-secondary;
      }
    }
    
    .doctor-list {
      white-space: nowrap;
      
      .doctor-item {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        width: 200rpx;
        margin-right: 30rpx;
        
        &:last-child {
          margin-right: 0;
        }
        
        .avatar {
          width: 160rpx;
          height: 160rpx;
          border-radius: 50%;
          margin-bottom: 16rpx;
        }
        
        .name {
          font-size: 30rpx;
          color: $text-primary;
          font-weight: bold;
          margin-bottom: 8rpx;
        }
        
        .title {
          font-size: 26rpx;
          color: $text-regular;
          margin-bottom: 8rpx;
        }
        
        .specialty {
          font-size: 24rpx;
          color: $text-secondary;
        }
        
        &:active {
          opacity: 0.8;
        }
      }
    }
    
    .case-list {
      .case-item {
        background: $bg-color;
        border-radius: $radius-lg;
        margin-bottom: 20rpx;
        overflow: hidden;
        
        &:last-child {
          margin-bottom: 0;
        }
        
        .case-image {
          width: 100%;
          height: 300rpx;
        }
        
        .content {
          padding: 20rpx;
          
          .title {
            font-size: 32rpx;
            color: $text-primary;
            font-weight: bold;
            margin-bottom: 12rpx;
            display: block;
          }
          
          .desc {
            font-size: 28rpx;
            color: $text-regular;
            margin-bottom: 16rpx;
            display: block;
          }
          
          .meta {
            display: flex;
            justify-content: space-between;
            font-size: 24rpx;
            color: $text-secondary;
          }
        }
        
        &:active {
          transform: scale(0.99);
        }
      }
    }
  }
}
</style>